from __future__ import absolute_import, unicode_literals
from celery import shared_task

from .serializers import Userserializers


@shared_task
def register(data):
    res_data = {}
    user = Userserializers(data=data)
    if user.is_valid():
            user.save()
            res_data['code'] = 200
            res_data['message'] = '注册成功'
    else:
        res_data['code'] = 10011
        print(user.errors)
        res_data['message'] = user.errors
    return res_data

